#ifndef SM4ENCRYPT_H
#define SM4ENCRYPT_H

#include <QObject>
#define SAR_OK							0X00000000
#define SGD_SM4_ECB		0x00000401
//#include "CommonType.h"
#include "iot_se_vendor.h"
#include "System/System.h"
class SM4Encrypt: public QObject
{
    Q_OBJECT
private :
    explicit SM4Encrypt(QObject *parent = 0);
    ~SM4Encrypt(){}
    SM4Encrypt(const SM4Encrypt &);
    SM4Encrypt &operator=(const SM4Encrypt &);

     static SM4Encrypt* m_pInstance;
     static QMutex m_Mutex;

     QTimer* timer;
     char m_szSeId[256];
     SEAPPINFO m_stSeAppInfo;
     char m_enCode[128];
    unsigned  char m_SignedCertData[8192];
    unsigned int m_SignedCertData_len;

    QByteArray m_SignedDataRaw;
     qint32 nRet;
     void* hEnv;
    bool isInit;
public:
     static SM4Encrypt* getInstance()
     {
         if(!m_pInstance)
         {
             QMutexLocker lock(&m_Mutex);
             if(!m_pInstance)
             {
                 SM4Encrypt *pInstance = new SM4Encrypt();
                 m_pInstance = pInstance;
             }
         }
         return m_pInstance;
     }
     qint32 initWXTPlatformDevice();
     QByteArray getGenP7AuthData();
     QByteArray getGenP7AuthDataRaw();
     bool getIsInit();
     char* getSeId();
   // SM4Encrypt();
     QByteArray getSignedCert();
     void Init();
     void ImportSessionKey(QByteArray key);
     QByteArray EncryptBySM4(QByteArray data);
     QByteArray DecryptBySM4(QByteArray data);
     void print16FormatData(QByteArray data);
signals:
    void sm4InitComlete();


private slots:
    void timeoutSlot();
};

#endif // SM4ENCRYPT_H
